<template>
	<view>
		<view class="jobCard mL15 mR15" v-for="(item,i) in list" :key="item.id" @click="jumpJobDetail(item)">
			<view class="flex  alg-center jst-between">
				<view class="w75 flex alg-center">
					<text class="jobTitle" :class="xf.getItemClass(item)">{{item.oddJobName}}</text>
					<u-tag v-if="item.izUrgent==1" text="急聘" bg-color="#fff" class="jpTag" :color="'#FF0000'" :border-color="'#FF0000'"
						 />
					<u-tag v-if="item.recruitmentCarefree&&item.recruitmentCarefree.indexOf('10')>=0" text="用工无忧" bg-color="#EAF4FE" class="zgTag" :color="'#3291F8'" :border-color="'#EAF4FE'"
						 />	
					
				</view>
				
				<view class="jobMoney txt-ellipsis  font20 u-red">{{item.salary}}<text class="jobUint font13">元</text>
				</view>
			</view>
			<view class="flex alg-center flex-wrap">
				<view class="jobTime">{{item.jobBeginDatetime}}-{{item.jobEndDatetime}}</view>
				<view class="jobTime">{{item.salaryPaymentText}}</view>
				<view class="jobTime">招{{item.oddJobUseNum}}人</view>
			</view>
			<view class="flex alg-center jst-between mT10">
				<view class="jobPos flex alg-center w70">
					<image class="posImg" :src="resources.posIcon" mode=""></image>
					<text class="posTxt mL5 txt-ellipsis">{{item.hopeWorkAddress}}</text>
				</view>
				<view class="font13 u-6">{{item.distance}}</view>
			</view>
			<view class="flex jst-between alg-center mT10">
				<view class="flex alg-center" @click.stop="jumpPersonInfo(item)">
					<u-image :width="48" :height="48" :borderRadius="10" v-if="item.userprofile" class="companyImg"
						:src="xf.getImgUrl(item.userprofile)" mode=""></u-image>
					<image v-else class="companyImg" :src="resources.defaultHeader" mode=""></image>
					<text class="companyName ellipse" style="max-width: 300rpx;">{{item.comOrUserName}}</text>
					<block v-if="item.comizAuthentication||item.comOrUserizAuthentication">
						<image v-if="item.oddReleaseType==1" :src="resources.qyrzLogo" class="rzImg" mode=""></image>
						<image v-else :src="resources.grrzLogo" class="rzImg" mode=""></image>
					</block>
				</view>
				<view v-if="item.enrollStatus==1" class="bmBtn" @click.stop="rightNowBm(item)">立即报名</view>
				<view v-else class="bg-gray u-6 radius20 pL20 pR20 line36">已报名</view>

			</view>

		</view>
		<xfTipModal ref="tipModal"></xfTipModal>
	</view>

</template>

<script>
	import {
		rightNowBm,
		findMakerByCardNumber
	} from '@/api/userInterface/job.js'
	export default {
		props: ['list'],
		data() {
			return {

			}
		},
		methods: {
			rightNowBm(v) {
				if (this.xf.isLogin()) {
					this.rightBmOpt(v)
				} else {
					this.$refs.tipModal.open({
						content: "您还未登录,请先登录",
						btnText: "去登录",
						showCancel: true,
						success: function() {
							uni.navigateTo({
								url: "/pages/login/login"
							})
						}
					})
				}

			},
			rightBmOpt(v) {
				let that = this;
				let uInfo = this.xf.onlineUtils.getUserInfo()
				if (uInfo.isAuthPersonal=="1") {
					this.$refs.tipModal.open({
						content: "您确定报名该职位吗？",
						btnText: "确认报名",
						showCancel: true,
						success: function() {
							findMakerByCardNumber({
								oddjobInfo: v.id,
							}).then(res=>{
								if(res.result.code != 200) return uni.showToast({
									title: res.result.msg,
									icon: 'none',
								})
								// 跳转结算
								if(typeof res.result.data === 'string'){
									setTimeout(() => {
										that.$refs.tipModal.open({
											content: "未绑定钱包，请先去绑定钱包",
											btnText: "确定",
											showCancel: true,
											success: function() {
												const encodedUrl = encodeURIComponent(res.result.data)
												uni.navigateTo({
													url: `/pages/common/webview/index?url=${encodedUrl}`
												});
											}
										})
									}, 300)
								} else if (res.result.data == true) {
									rightNowBm({
										"xfOddjobInfoId": v.id,
										"xfOddjobInfoName": v.oddJobName
									}).then(res => {
										if (res.success == true) {
											v.enrollStatus = 0;
											uni.showToast({
												icon: 'none',
												title: "报名成功!",
												duration: 2000
											})
										}
									}).catch(err => {
										console.log(err)
									})
								}
								
							})
							
						}
					})

				} else {
					this.$refs.tipModal.open({
						content: "您还未进实名认证，请先实名认证？",
						btnText: "去认证",
						showCancel: true,
						success: function() {
							uni.navigateTo({
								url: "/pages/userPage/subpackge/my/smrz/smrz"
							})
						}
					})
				}

			},
			jumpPersonInfo(item) {
				let id = item.oddReleaseType == 1 ? item.comId : item.xfOddUserId
				uni.navigateTo({
					url: `/pages/common/personOrcompnayInfo/index?isPerson=${item.oddReleaseType}&id=${id}`
				})
			},
			jumpJobDetail(item) {
				uni.navigateTo({
					url: `/pages/userPage/subpackge/oddJob/jobDetail/jobDetail?id=${item.id}`,
				})

			}

		}
	}
</script>

<style lang="scss" scoped>
	.jobCard {
		padding: 20rpx 30rpx;
		margin-bottom: 20rpx;
		background: #FFFFFF;
		border-radius: 20rpx;

		.jobName {
			// max-width:200rpx;
		}

		.jobLeft {
			width: 70%;
		}

		.jobStatus {
			border: 2rpx solid #FF0000;
			border-radius: 10rpx;
			height: 40rpx;
			line-height: 40rpx;
			padding: 0 10rpx;
			margin-right: 10rpx;
			margin-top: 16rpx;
		}

		.jobTag {
			height: 44rpx;
			line-height: 44rpx;
			padding: 0 10rpx;
			background: #F8F8F8;
			border-radius: 6rpx;
			margin-top: 16rpx;
		}

		.jobMoney {
			word-break: keep-all;
		}

		.jobTime {
			color: #8D8D8D;
			font-size: 26rpx;
			margin-right: 10rpx;
			height: 44rpx;
			line-height: 44rpx;
			padding: 0 20rpx;
			background: #F8F8F8;
			border-radius: 6rpx;
			margin-top: 16rpx;
		}

		.posImg {
			width: 32rpx;
			height: 32rpx;
		}

		.posTxt {
			width: calc(100% - 42rpx);
			font-weight: 400;
			font-size: 26rpx;
			color: #8D8D8D;
		}

		.companyImg {
			width: 48rpx;
			height: 48rpx;
		}

		.rzImg {
			width: 24rpx;
			height: 24rpx;
		}

		.companyName {
			font-weight: 500;
			font-size: 30rpx;
			color: #333;
			margin-right: 10rpx;
			margin-left: 10rpx;
		}
	}
</style>